<html>
<head><meta charset="utf-8"><title>move errors: partial assignments to moved variables · t-compiler/wg-polonius · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/index.html">t-compiler/wg-polonius</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/move.20errors.3A.20partial.20assignments.20to.20moved.20variables.html">move errors: partial assignments to moved variables</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="202324622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/move%20errors%3A%20partial%20assignments%20to%20moved%20variables/near/202324622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrea Lattuada <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/move.20errors.3A.20partial.20assignments.20to.20moved.20variables.html#202324622">(Jun 29 2020 at 15:14)</a>:</h4>
<p>Ah, and as a result of today’s experiments, I added a rule to emit errors for partial assignments to moved variables: <a href="https://github.com/rust-lang/polonius/compare/master...utaal:partial-move-errors">https://github.com/rust-lang/polonius/compare/master...utaal:partial-move-errors</a> <br>
I believe (correct me if I’m wrong) that these are currently handled by a separate rustc pass. As an example, with this branch you get a <code>partial_move_error</code> fact for</p>
<div class="codehilite"><pre><span></span><code>struct Lin { v: u64 }

fn main() {
    let mut a: Lin = Lin { v: 3 };
    take(a);
    a.v = 7; // &lt;- this assignment
}

fn take&lt;V&gt;(_v: V) { }
</code></pre></div>


<p>My level of confidence this is correct in general is of course very low, but it has worked correctly on a few basic examples.</p>



<a name="202339924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/move%20errors%3A%20partial%20assignments%20to%20moved%20variables/near/202339924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/move.20errors.3A.20partial.20assignments.20to.20moved.20variables.html#202339924">(Jun 29 2020 at 17:07)</a>:</h4>
<p>yes move errors are still currently computed and emitted by rustc itself. polonius also computes them but they are not emitted by rustc yet instead of its own computation. (that also means we haven't had a chance to fully debug them yet either)</p>



<a name="202411825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/move%20errors%3A%20partial%20assignments%20to%20moved%20variables/near/202411825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrea Lattuada <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/move.20errors.3A.20partial.20assignments.20to.20moved.20variables.html#202411825">(Jun 30 2020 at 09:18)</a>:</h4>
<p>From what I can see, polonius currently computes move errors for points where an uninitialized (moved) path is accessed, but not for points where a path is assigned (like in the example above). The new rule introduced by this <a href="https://github.com/rust-lang/polonius/compare/master...utaal:partial-move-errors">https://github.com/rust-lang/polonius/compare/master...utaal:partial-move-errors</a> is an attempt to compute errors for partial assignments to uninitialized variables. Shall I make an Issue/PR for this?</p>



<a name="202415793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/move%20errors%3A%20partial%20assignments%20to%20moved%20variables/near/202415793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/move.20errors.3A.20partial.20assignments.20to.20moved.20variables.html#202415793">(Jun 30 2020 at 10:02)</a>:</h4>
<p>an issue would be super useful, until we can hook move errors to rustc and see all that's missing, in order to check and modify all the rules at once</p>



<a name="202415824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/move%20errors%3A%20partial%20assignments%20to%20moved%20variables/near/202415824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/move.20errors.3A.20partial.20assignments.20to.20moved.20variables.html#202415824">(Jun 30 2020 at 10:02)</a>:</h4>
<p>but this specific case might be of interest to <span class="user-mention" data-user-id="204115">@Albin Stjerna</span> who worked on move errors</p>



<a name="202425569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/move%20errors%3A%20partial%20assignments%20to%20moved%20variables/near/202425569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrea Lattuada <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/move.20errors.3A.20partial.20assignments.20to.20moved.20variables.html#202425569">(Jun 30 2020 at 12:04)</a>:</h4>
<p><a href="https://github.com/rust-lang/polonius/issues/152">https://github.com/rust-lang/polonius/issues/152</a></p>



<a name="203017390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/move%20errors%3A%20partial%20assignments%20to%20moved%20variables/near/203017390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/move.20errors.3A.20partial.20assignments.20to.20moved.20variables.html#203017390">(Jul 06 2020 at 17:24)</a>:</h4>
<p>It's been a while, but IIRC I intentionally left this check out because I figured we might want to support partial assignments, provided they were safe, and that the more granular move analysis performed by Polonius would be enough to handle them.</p>



<a name="203017424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/move%20errors%3A%20partial%20assignments%20to%20moved%20variables/near/203017424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/move.20errors.3A.20partial.20assignments.20to.20moved.20variables.html#203017424">(Jul 06 2020 at 17:24)</a>:</h4>
<p>Still, for checking against rustc to verify errors? Possibly a good idea</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>